import os
from conf_inf_F48P21 import *

# import gamma_torch as gac




def Pair_mom(P,P_K):
    Pi_sesk=[]
    K_sesk=[]
    X_sesk=[]
    PiK_K=[]
    for i,P_se in enumerate(P):
        for j in range(0,len(P)):
            P_sk=P[j]
            Pi_sesk.append((P_se[0],P_sk[0]))
            K_sesk.append((P_se[1],P_sk[1]))
            if (j>=i):
                X_sesk.append((P_se,P_sk))
        for p in P_K:
            PiK_K.append((P_se,p))
    return Pi_sesk,K_sesk, X_sesk,PiK_K
P0=[( 0,0,0 ),]
P1=[(1,0,0),(0,1,0),(0,0,1)]
P2=[ (1,1,0), (1,0,1), (0,1,1) , (-1,1,0), (-1,0,1), (0,-1,1)]
P3=[ (1,1,1),  (-1,1,1) , (1,-1,1) , (1,1,-1)]
# P_dic={0:P0,1:P1,2:P2,3:P3}

# VdV_PxPyPz = [( 0,0,0 ),(1,0,0),(0,1,0),(0,0,1),
        # (1,1,0),(1,0,1),(0,1,1),(-1,1,0),(-1,0,1),(0,-1,1),
        # (1,1,1),(-1,1,1),(1,-1,1),(1,1,-1), # len=13
        # (-1,0,0),(0,-1,0),(0,0,-1),
        # (-1,-1,0),(-1,0,-1),(0,-1,-1),(1,-1,0),(1,0,-1),(0,1,-1),
        # (-1,-1,-1),(1,-1,-1),(-1,1,-1),(-1,-1,1)]

Pi0K0_tot0=( ((0,0,0),(0,0,0)), )
Pi1K1_tot0=( ((1,0,0),(-1,0,0)), ( (0,1,0),(0,-1,0) ), 
             ((0,0,1),(0,0,-1) ),( (-1,0,0),(1,0,0)),
             ((0,-1,0),(0,1,0) ),( (0,0,-1),(0,0,1) ) )

Pi2K2_tot0= ( ((1,1,0),(-1,-1,0)), ( (1,0,1),(-1,0,-1) ), 
             ((0,1,1),(0,-1,-1) ),( (-1,1,0),(1,-1,0)),
             ((-1,0,1),(1,0,-1) ),( (0,-1,1),(0,1,-1) ),
             ((-1,-1,0),(1,1,0)), ( (-1,0,-1),(1,0,1) ), 
             ((0,-1,-1),(0,1,1) ),( (1,-1,0),(-1,1,0)),
             ((1,0,-1),(-1,0,1) ),( (0,1,-1),(0,-1,1) ) )

Pi3K3_tot0= ( ((1,1,1),(-1,-1,-1)), ( (-1,1,1),(1,-1,-1) ), 
             ((1,-1,1),(-1,1,-1) ),( (1,1,-1),(-1,-1,1)),
             ((-1,-1,-1),(1,1,1) ),( (1,-1,-1),(-1,1,1) ),
             ((-1,1,-1),(1,-1,1)), ( (-1,-1,1),(1,1,-1) ) )
Ki0=[ ((0,0,0),(0,0,0)),]

Ki1=[]
for i in range(len(P1)):
    for j in range(i,len(P1)):
        Ki1.append((P1[i],P1[j]))
Ki2=[]
for i in range(len(P2)):
    for j in range(i,len(P2)):
        Ki2.append((P2[i],P2[j]))
Ki3=[]
for i in range(len(P3)):
    for j in range(i,len(P3)):
        Ki3.append((P3[i],P3[j]))
P_tot0=Pi0K0_tot0 + Pi1K1_tot0+Pi2K2_tot0 
Pi_sesk_tot0, K_sesk_tot0, X_sesk_tot0,PiK_K_tot0 = Pair_mom(P_tot0,P0)
Pi_sesk_t, K_sesk_t, X_sesk_t,PiK_K_t= Pair_mom(Pi0K0_tot0,P0)


Pi0K1_tot1=( ((0,0,0),(1,0,0)),( (0,0,0),(0,1,0) ), ( (0,0,0), (0,0,1) ) )
Pi1K0_tot1=( ((1,0,0),(0,0,0)),( (0,1,0),(0,0,0) ), ( (0,0,1), (0,0,0) ) )
Pi1K2_tot1=( ((1,0,0),(-1,0,1)), 
        ((0,1,0),(0,-1,1)), 
        ((-1,0,0),(1,0,1)), 
        ((0,-1,0),(0,1,1)))
Pi2K1_tot1=tuple([ (P[1],P[0]) for P in Pi1K2_tot1 ])

Pi2K3_tot1=( ((1,1,0), (-1,-1,1)), 
        ( (1,-1,0),(-1,1,1) ), 
        ((-1,1,0), (1,-1,1)),
        ( (-1,-1,0),(1,1,1) ) )
Pi3K2_tot1= tuple([  (P[1],P[0]) for P in Pi2K3_tot1  ])
P_tot1=Pi0K1_tot1+Pi1K0_tot1+Pi2K1_tot1+Pi1K2_tot1

Pi_sesk_tot1, K_sesk_tot1, X_sesk_tot1,PiK_K_tot1 = Pair_mom(P_tot1,P1)


Pi0K2_tot2=( ( (0,0,0),(0,1,1) ), ( (0,0,0),(1,0,1) ), (
    (0,0,0),(1,1,0) ), ( (0,0,0),(-1,1,0) ),
    ((0,0,0),(-1,0,1)),((0,0,0),(0,-1,1)) )
Pi2K0_tot2 = tuple( [ (P[1],P[0]) for P in Pi0K2_tot2] )
Pi1K3_tot2=( ((1,0,0),(-1,1,1)),((-1,0,0),(1,1,1)),((0,1,0),(1,-1,1))
        ,((0,-1,0),(1,1,1)),((0,0,1),(1,1,-1)),((0,0,1),(1,1,1)))
P_tot2 = Pi2K0_tot2+Pi0K2_tot2
Pi_sesk_tot2, K_sesk_tot2, X_sesk_tot2 ,PiK_K_tot2= Pair_mom(P_tot2,P2)
